package com.bkhech.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * StaticResourceConfig
 *   本地文件存储服务文件地址映射配置，用来测试，分布式情况下使用 minio 存储服务
 * @author guowm
 * @date 2024-11-07
 */
@Configuration
@Slf4j
public class StaticResourceConfig extends WebMvcConfigurationSupport {

    /**
     * 添加静态文件映射路径
     *
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                // 注意注意：这里是三个斜杠
                .addResourceLocations("file:///D:/upload/");
        super.addResourceHandlers(registry);
    }
}
